package com.controller;

import java.awt.Color;

import javax.swing.JLabel;
import javax.swing.JTextField;
//asdasdas
public class BugCon {
	private final static String IS_NUMBER = "\\d*";
	private final static String IS_DATE = "\\d{4}-\\d{1,2}-\\d{1,2}";
	static String rx = null;
	public static Boolean actionBug(JTextField jtf, JLabel jl,String name) {
		if(name.equals("数量") || name.equals("价格") || name.equals("编号")) {
			rx = IS_NUMBER;
		}else if(name.equals("入库时间")) {
			rx = IS_DATE;
		}
		if(jtf.getText().matches(rx) || "".equals(jtf.getText()) || jtf.getText() == null) {
			jl.setForeground(Color.black);
			return false;
		}else {
			jl.setForeground(Color.red);
			return true;
		}
	}

}
